package tests;

import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num = 0;
        if(n==1||n==2){
            num=-1;
        }else{
            n-=2;
            if(n%4==1||n%4==3){
                num=2;
            }else if(n%4==0){
                num=4;
            }else{
                num=3;
            }
        }
        System.out.println(num);
    }
}
